const previewFileTypes = new Set([
  'application/pdf',
  'application/msword',
  'application/vnd.ms-wordml',
  'application/vnd.ms-excel',
  'application/octet-stream',
  'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  'text/plain',
  'text/html',
  'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  'application/vnd.ms-powerpoint',
  'application/x-tika-ooxml',
  'application/x-tika-msoffice',
  'application/xml'
])
const previewFileExt = new Set([
  'docx',
  'pptx',
  'xlsx',
  'doc',
  'ppt',
  'xls'])
const previewFile = function (node) {
  let mime = node.mime || node.fileMime
  let name = node.name || node.fileName
  // let preFileId = node.preFileId
  let canPreview = false
  // if (!preFileId) {
  //   return false
  // }
  if (previewFileTypes.has(mime)) {
    canPreview = true
  }
  if (mime === 'application/zip') {
    const extName = name.substring(name.lastIndexOf('.') + 1, name.length)
    if (previewFileExt.has(extName.toLowerCase())) {
      canPreview = true
    }
  }
  return canPreview
}

export default previewFile
